<!DOCTYPE html>
<html>
<head>
    <meta name="author" content="ginko"/>
    <meta charset="utf-8"/>
    <meta http-equiv="content-type" content='text/html;charset=UTF-8'/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="msapplication-tap-highlight" content="no"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no">
    <style>
        html, body {
            padding: 0;
            margin: 0;
            font-size: 16px;
            background-color: dimgray;
        }

        .echarts {
            position: absolute;
            width: 100%;
            height: 100%;
        }

    </style>
</head>
<body class="body">
<div id="main" class="main echarts"></div>
<section>
    <script charset="utf-8" type="text/javascript" src="./js/jquery.js?v=0a83d"></script>
    <script charset="utf-8" type="text/javascript" src="./js/Logger.js?v=0a83d"></script>
    <script charset="utf-8" type="text/javascript" src="./js/echarts.min.js?v=0a83d"></script>
    <script charset="utf-8" type="text/javascript" src="./js/itit.common.js?v=0a83d"></script>
    <script charset="utf-8" type="text/javascript" src="./js/itit.map.js?v=0a83d"></script>
    <script>
        $(function () {

            var updateMapView = function (chart, map) {
                chart.showLoading();
                if (!map) {
                    alert("未找到对应地图信息");
                    chart.hideLoading();
                    return;
                }
                $.get("./" + map.json, function (geoJson) {
                    //debugger
                    chart.hideLoading();
                    echarts.registerMap(map.code, geoJson);
                    var features = geoJson.features;
                    var data = [];
                    var defines = [];
                    for (var i = 0; i < features.length; i++) {
                        var feature = features[i];
                        data.push({
                            name: feature.properties.name,

                            itemStyle: {
                                normal: {
                                    areaColor: 'transparent',
                                    shadowColor: "rgba(0,0,0.3)"
                                }
                            }
                        });
                        defines.push({
                            name: feature.properties.name,
                            code: feature.id,
                            json: "/map/geo/" + feature.id + ".json"
                        });
                    }
                    chart.setOption({
                        selectedMode: "single",
                        toolbox: {
                            show: true,
                            feature: {
                                restore: {show: true},
                                saveAsImage: {show: true},
                            }
                        },
                        tooltip: {
                            trigger: 'item',
                            formatter: '{b}'
                        },
                        series: [{
                            type: "map",
                            mapType: map.code,
                            roam: true,
                            label: {
                                normal: {
                                    show: true
                                },
                                emphasis: {
                                    show: true
                                }
                            },
                            data: data
                        }]
                    });
                });
            };

            var mapChart = echarts.init(document.getElementById('main'));
            updateMapView(mapChart, itit.map.getByCode("520100"));

        });
    </script>
</section>
</body>
</html>